<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="js/jquery-1.11.0.min.js"></script>

</head>
<body>
<div><form id="form">
  <p id="caozuo">充值操作</p> <br>
  <input type="hidden" name="id" id="id">
  一类卡卡号：<input type="text" id="id1" name="id1" placeholder="请输入一类卡卡号"> <br>
  姓名：<input type="text" id="name" name="name" placeholder="请输入姓名"> <br>
  手机号：<input type="text" id="phone" name="phone"placeholder="请输入手机号"> <br>
  支付密码：<input type="password" id="password" name="password"placeholder="请输入支付密码"> <br>
  充值金额：<input type="text" id="money" name="money"placeholder="请输入充值金额"> <br>
  <input type="button" id="chongzhiBtn" value="充值">
</form></div>
<table width="100%" id="shouye">
  <tr>
    <td align="center"><a href="/airong/index.html">首页</a></td>
    <!--    <td align="center"><a href="#"><input type="button" id="lc" value="理财"></a></td>-->
    <td align="center"><a href="" id="lc">理财</a></td>
    <td align="center"><a href="/airong/personalCenter.html">我的</a></td>

  </tr>
</table>

</body>
<script>
  $("#chongzhiBtn").click(function (){
    let id2 = getUrlParms("id")
    let name = $("#name").val()
    let id1 = $("#id1").val()
    let phone = $("#phone").val()
    let password = $("#password").val()
    let money = $("#money").val()
    let url = "/airong/card?action=chongzhi"
    let params = {id2,name,id1,phone,password,money}
    $.post(url,params,function (data){
      if (data === "\"lowBalance\""){
        alert("一类卡余额不足")
      }else if (data === "\"false\""){
        alert("查无此卡")
      }else {
        let c = confirm("确定要充值"+money+"元吗")
        if (c == true){
          alert("充值成功")
          location.href = "account.html"
        }else {
          alert("充值失败")
        }
      }
    },"text")
  })
  function getUrlParms (name) {
    let url = window.location.href;//获取请求进来的完整url
    let tstr = url.substring(url.indexOf('?') + 1).split('&');//先截取url的?后面的参数部分，在根据&分割成参数数组
    let result = {};
    tstr.forEach((item) => {
      let res = item.split('=');//res为type,my-component1.vue。  res[0]为type，res[1为]my-component1.vue
      result[res[0]] = res[1];//构造成键值对形式 res[0]为键，res[1]为值 例：type: "my-component1.vue"
    });
    return result[name];//通过键取值
  };
  let urll = "/airong/cc?action=getSessionID";
  let paramsl = {}
  $.get(urll,paramsl,function (sessionID){
    document.getElementById('lc').href= "products.html?uid="+sessionID;
  },"text")

</script>
<style>
  div {

    width: 100%;
    text-align: center;
  }
  input{
    padding: 10px;
    margin: 10px;
    text-align: left;
  }
  #shouye{
    position: absolute;
    top: 600px;
    padding: 5px;
    margin: 4px;
    background-color: bisque;
    font-size: 20px;
    text-align: center;
    z-index: 1;
  }

</style>
</html>